package com.map;

import static com.map.Constant.RADIO;

/**
 * Description: load
 * <p>
 * Created by 韩博 on 2020/4/26 14:35
 */
public class Point {
    private double x;
    private double y;

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    /**
     * 4326坐标系转3857
     * @constructor
     */
    public static Point Wgs84ToMector (Point point){
        double x = point.getX() * RADIO;
        double y = Math.log(Math.tan((90 + point.getY()) * Math.PI / 360)) / Math.PI * 180;
        y = y * RADIO;
        return new Point(x,y);
    }

    /**
     * 4326坐标系转3857
     * @constructor
     */
    public static Point MectorToWgs84 (Point point){
        double x = point.getX() /RADIO;
        double y= point.getY() /RADIO;
        y = 180/Math.PI*(2*Math.atan(Math.exp(y*Math.PI/180))-Math.PI/2);
        return new Point(x,y);
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
